﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GalaSoft.MvvmLight.Command;
using PocketBook.UI.ViewModel.Dialogs;
using PocketBook.UI.View;

namespace PocketBook.UI.ViewModel.Dialogs
{
    public class ConfirmDialogViewModel : BaseDialogViewModel
    {
        private Action _callback;

        #region Constructor

        public ConfirmDialogViewModel(PocketBookDialog window, string message, Action callback)
            : base (window)
        {
            _callback = callback;
            Message = message;
        }

        #endregion

        #region Message

        private const string MessagePropertyName = "Message";
        private string _message;
        public string Message 
        { 
            get 
            {
                return _message;
            } 
            set 
            {
                if (_message == value)
                {
                    return;
                }
                _message = value;
                RaisePropertyChanged(MessagePropertyName);
            } 
        }

        #endregion

        #region Commands

        private RelayCommand _deleteCommand;
        public RelayCommand DeleteCommand
        {
            get
            {
                if (_deleteCommand == null)
                {
                    _deleteCommand = new RelayCommand(
                        () =>
                        {
                            _callback.Invoke();
                            CloseWinow.Execute(null);
                        });
                }
                return _deleteCommand;
            }
        }

        #endregion
    }
}
